package com.example.demo.controller;


import com.example.demo.entity.TxhsVirtualshop;
import com.example.demo.service.XhsService;
import com.example.demo.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/xiaohongshu")
public class XhsController {
    @Autowired
    private XhsService xhsService;


    @ApiOperation(value = "查询")
    @RequestMapping(value = "/findAll", method = RequestMethod.POST)
    public List<TxhsVirtualshop> getAllUsers() {
        return xhsService.getAllUsers();
    }

    @ApiOperation(value = "删除")
    @RequestMapping(value = "/dels", method = RequestMethod.POST)
    public boolean delsss(@RequestParam int id) {
        return xhsService.DeleteById(id);
    }

    @ApiOperation(value = "添加虚拟店铺")
    @RequestMapping(value = "/addXhlshop", method = RequestMethod.POST)
    public boolean addXhlshop(@RequestParam int beReal, @RequestParam String customer_id, @RequestParam String shopType, @RequestParam String shopName) {
        return xhsService.addXhlshop(customer_id, shopType, shopName, beReal);
    }


    @ApiOperation(value = "更新虚拟店铺")
    @RequestMapping(value = "/updateXhsvirtual", method = RequestMethod.POST)
    public ResponseEntity<Result<TxhsVirtualshop>> updateXhsvirtual(@RequestBody   TxhsVirtualshop txhsVirtualshop) {
        Result<TxhsVirtualshop> result = xhsService.updateXhsvirtual(txhsVirtualshop);
        if (result.isSuccess()) {
            return new ResponseEntity<>(result, HttpStatus.OK);
        } else {
            return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }

}